package com.ly.mpayment.core.util;

import java.text.SimpleDateFormat;
import java.util.Date;

import net.sf.json.JsonConfig;
import net.sf.json.processors.JsonValueProcessor;

/** 
 * @ClassName: JsonValueFormat 
 * @Description: TODO json数据格式工具类
 * @date 2013-7-9 上午11:02:18 
 *  
 */  
public class JsonValueFormat implements JsonValueProcessor {
	
	//日期格式  
    private String pattern="yyyy-MM-dd HH:mm:ss"; 
    
    public JsonValueFormat() {
		super();
		
	}
    
	public JsonValueFormat(String pattern) {
		super();
		this.pattern = pattern;
	}
	
	public Object processArrayValue(Object value, JsonConfig jsonConfig) {
		if(value instanceof Date){ 
            String format=new SimpleDateFormat(pattern).format(value); 
            return format; 
        } 
		return null;
	}

	public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
		if(value instanceof Date){ 
            String format=new SimpleDateFormat(pattern).format(value); 
            return format; 
        } 
        return null; 
	}

}
